<script setup lang="ts">
	import { ref } from "vue";
	import { formRules } from "./utils/rule";
	import { FormProps } from "./utils/types";
	import ReCol from "@/components/ReCol";
	const props = withDefaults(defineProps<FormProps>(), {
		formInline: () => ({
			title: "",
			status: 0,
			Id: 0,
		})
	});
	const ruleFormRef = ref();
	const newFormInline = ref(props.formInline);
	function getRef() {
		return ruleFormRef.value;
	}
	defineExpose({ getRef });
</script>

<template>
	<el-form ref="ruleFormRef" :model="newFormInline" :rules="formRules" label-width="auto">
		<el-row :gutter="30">
			<re-col :value="12" :xs="24" :sm="24">
				<!-- <el-form-item label="部分ID" prop="departmentId">
					<el-input v-model="newFormInline.departmentId" clearable placeholder="请输入部分ID" />
					
				</el-form-item> -->
				
				<el-form-item label="上级部门" >
				  <el-cascader
					v-model="newFormInline.parentId"
					class="w-full"
					:options="newFormInline.higherDeptOptions"
					:props="{
					  value: 'id',
					  label: 'name',
					  emitPath: false,
					  checkStrictly: true
					}"
					clearable
					filterable
					placeholder="请选择上级部门"
				  >
					<template #default="{ node, data }">
					  <span>{{ data.name }}</span>
					  <span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
					</template>
				  </el-cascader>
				</el-form-item>
			</re-col>
			<re-col :value="12" :xs="24" :sm="24">
				<el-form-item label="部门名称" prop="name">
					<el-input v-model="newFormInline.name" clearable placeholder="请输入部门名称" />
				</el-form-item>
			</re-col>
			<re-col :value="12" :xs="24" :sm="24">
				<el-form-item label="排序" prop="sort">
					<el-input-number
						v-model="newFormInline.sort"
						class="!w-full"
						:min="0"
						:max="9999"
						controls-position="right"
					  />
				</el-form-item>
			</re-col>
			
			<!-- <re-col :value="12" :xs="24" :sm="24">
				<el-form-item label="备注" prop="remarks">
					<el-input v-model="newFormInline.remarks" clearable placeholder="请输入备注" />
				</el-form-item>
			</re-col> -->
		</el-row>
	</el-form>
</template>
<style scoped>
	.avatar-uploader .el-upload {
		border: 1px dashed var(--el-border-color);
		border-radius: 6px;
		cursor: pointer;
		position: relative;
		overflow: hidden;
		transition: var(--el-transition-duration-fast);
	}

	.avatar-uploader .el-upload:hover {
		border-color: var(--el-color-primary);
	}

	.el-icon.avatar-uploader-icon {
		font-size: 28px;
		color: #8c939d;
		width: 178px;
		height: 178px;
		text-align: center;
	}
</style>